package com.juli.aimanager.util;

public class TableGridJson {
	
	public static String getTableGridJson(TableGrid table){
		
		String append="{";
		if(table.getTitle()!=null&&!"".equals(table.getTitle())){
			append+=" title:'"+table.getTitle()+"'  ";
		}
		if(table.getField()!=null&&!"".equals(table.getField())){
			append+=" ,field:'"+table.getField().toUpperCase()+"'  ";
		}
		if(table.getAlign()!=null&&!"".equals(table.getAlign())){
			append+=", align:'"+table.getAlign()+"'  ";
		}
		if(table.getHidden()!=null&&!"".equals(table.getHidden())){
			append+=", hidden:"+table.getHidden()+"  ";
		}
		if(table.getSortable()!=null&&!"".equals(table.getSortable())){
			append+=", sortable:"+table.getSortable()+"  ";
		}
		if(table.getFormatter()!=null&&!"".equals(table.getFormatter())){
			append+=", formatter:"+table.getFormatter()+"  ";
		}
		
		if("1".equals(table.getCheckbox())){
			append+=", checkbox:true  ";
		}
		
		if(table.getResizable()!=null&&!"".equals(table.getResizable())){
			append+=", resizable:"+table.getResizable()+"  ";
		}
		
		if(table.getWidth()!=null&&!"".equals(table.getWidth())){
			append+=", width:"+table.getWidth()+"  ";
		}
		
		append+=" } ";
		return append;
		
	}
	
	public static void main(String args []){
		TableGrid tableGrid=new TableGrid();
		tableGrid.setAlign("center");
		tableGrid.setTitle("����վ");
		tableGrid.setField("nodename");
		tableGrid.setSortable("true");
		System.out.println(TableGridJson.getTableGridJson(tableGrid));
	}

}
